import React, { Component } from 'react';
import { Button } from 'antd';
import * as actions from './redux/actions';

export default class APP extends Component{
  state = {
    count:0
  }
  increase = () =>{
    const number = this.select.value;
    // const count = this.state.count*1 + number*1;
    // this.setState({count});
    console.log(this.props.store.getState());
    // 调用store的方法更新状态
    this.props.store.dispatch(actions.increase(number));
  }
  decrease = () =>{
    const number = this.select.value;
    // const count = this.state.count*1 - number*1;
    // this.setState({count});
    this.props.store.dispatch(actions.decrease(number));
  }

  render(){
    //const count = this.state.count;
    const count = this.props.store.getState();
    return(
      <div>
        <h3>number is {count} </h3>
        <select ref={select => this.select = select}>
          <option value="1">1</option>
          <option value="3">3</option>
          <option value="4">4</option>
        </select>
        <Button onClick={this.increase}>+</Button>
        <Button onClick={this.decrease}>-</Button>
      </div>
    );
  }
}